package com.wengluobiancheng.demo06;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ServerDemo01 {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(20001);
        ThreadPoolExecutor s1 = new ThreadPoolExecutor(3, 6, 60,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(5),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        while (true) {
            Socket a = ss.accept();

            ThreadSocket01 ts = new ThreadSocket01(a);
            //new Thread(ts).start();
            s1.submit(ts);

            //bos.close();

            // bw.close();
        }

        // ss.close();
    }
}
